import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../widgets.dart';

///用户： ninetailedfox
///时间： 2020/6/14
///邮箱： 1037438704@qq.com
///功能： 通知页面的所有组件

class SwitchClassesWidget extends StatelessWidget {
  final VoidCallback onTap;
  final TextEditingController textEditingController;

  SwitchClassesWidget({this.onTap,this.textEditingController});

  @override
  Widget build(BuildContext context) {
    return ShadowWidget(
      externalPadding: EdgeInsets.only(
          left: ScreenUtil().setWidth(35),
          right: ScreenUtil().setWidth(35),
          bottom: ScreenUtil().setWidth(35),
          top: ScreenUtil().setWidth(35)),
      childWidget: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text("加入新班级", style: TextStyles.textDark43),
          Padding(
            padding: EdgeInsets.only(
              bottom: ScreenUtil().setWidth(26),
              left: ScreenUtil().setWidth(175),
              right: ScreenUtil().setWidth(175),
            ),
            child: TextField(
//是否显示密码
              obscureText: false,
//是否禁用
              autofocus: false,
              controller: textEditingController,
              minLines: 1,
//                        keyboardType: textInputType ?? TextInputType.number,
//                        maxLength: length ?? 11,
              style: TextStyles.textDark43,
              textAlign: TextAlign.center,
              decoration: InputDecoration(
                contentPadding: EdgeInsets.only(
                    bottom: ScreenUtil().setWidth(38),
                    top: ScreenUtil().setWidth(38)),
                focusedBorder: UnderlineInputBorder(
//选中时外边框颜色
                  borderSide: BorderSide(color: Colors.blue),
                ),
                hintText: '输入班级代码',
                counterText: "",
//此处控制最大字符是否显示
                hintStyle: TextStyles.textGrey43,
              ),
            ),
          ),
          Container(
            height: ScreenUtil().setWidth(100),
            padding: EdgeInsets.only(
              right: ScreenUtil().setWidth(355),
              left: ScreenUtil().setWidth(355),
              bottom: ScreenUtil().setWidth(35),
            ),
            child: MaterialButton(
              minWidth: double.infinity,
              //按钮失效时的颜色
              disabledColor: Colors.grey,
              //按钮背景色
              color: Colors.blue,
              //点击按钮时水波纹颜色
//      splashColor: ColorHelper.mainPressBlueColor,
              //长按后的颜色
//      highlightColor: ColorHelper.disableColor,
              //阴影的范围，值越大阴影范围越大
//        elevation: 100.0,
              shape: StadiumBorder(),
              child: Text("立即加入", style: TextStyles.textWhite30),
              onPressed: onTap,
            ),
          )
        ],
      ),
      onTap: null,
    );
  }
}

///Glide列表
class GridViewWidget extends StatelessWidget {
  final List listImagUrl;
  GridViewWidget({this.listImagUrl});


  @override
  Widget build(Object context) {
    return GridView.builder(
      shrinkWrap: true,
      itemCount: listImagUrl?.length??0,
      physics: NeverScrollableScrollPhysics(),
      padding: EdgeInsets.symmetric(horizontal: 16),
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 5,
        mainAxisSpacing: 5,
        crossAxisSpacing: 5,
        childAspectRatio: 1,
      ),
      itemBuilder: (context, index) {
        return Column(
          children: <Widget>[
            listImagUrl != null?Image.network(
              listImagUrl[index]["icon"],
              width: ScreenUtil().setWidth(97),
              height: ScreenUtil().setWidth(97),
            )
                : Image.asset(
              Utils.getImgPath("yuwen"),
              width: ScreenUtil().setWidth(97),
              height: ScreenUtil().setWidth(97),
            ),
            Text(
              listImagUrl[index]["name"]??"",
              style: TextStyles.textDark28,
            )
          ],
        );
      },
    );
  }
}
